/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Client.java
 *
 * Created on 18/Mai/2009, 22:16:06
 */

package Viewer;

import Socket.Coelho.CoelhoSocket;
import javax.swing.JOptionPane;

/**
 *
 * @author tomax
 */
public class Client extends javax.swing.JFrame {
    private Thread C;
    /** Creates new form Client */
    public Client() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        addresslbl = new javax.swing.JLabel();
        addressfield = new javax.swing.JTextField();
        portlbl = new javax.swing.JLabel();
        portfield = new javax.swing.JTextField();
        startbutton = new javax.swing.JButton();
        radiorabbit = new javax.swing.JRadioButton();
        radiocarrot = new javax.swing.JRadioButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        addresslbl.setText("Endereço");

        addressfield.setText("localhost");

        portlbl.setText("Porta");

        portfield.setText("5000");

        startbutton.setText("Iniciar");
        startbutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startbuttonActionPerformed(evt);
            }
        });

        buttonGroup1.add(radiorabbit);
        radiorabbit.setText("Coelho");

        buttonGroup1.add(radiocarrot);
        radiocarrot.setText("Cenoura");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(radiocarrot)
                    .addComponent(radiorabbit)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(addresslbl)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(addressfield, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(portlbl)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(portfield, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(39, 39, 39)
                        .addComponent(startbutton)))
                .addContainerGap(74, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(addressfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(portfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(addresslbl)
                    .addComponent(portlbl)
                    .addComponent(startbutton))
                .addGap(18, 18, 18)
                .addComponent(radiorabbit)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(radiocarrot)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void startbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startbuttonActionPerformed
        if (radiocarrot.isSelected()){
            JOptionPane.showMessageDialog(null, "Selecionada a Cenoura em => " + addressfield.getText() + ":" + portfield.getText());
            //TODO
        }
        else if(radiorabbit.isSelected()){
            JOptionPane.showMessageDialog(null, "Selecionado o Coelho em => " + addressfield.getText() + ":" + portfield.getText());
            //C = new Thread(new CoelhoSocket(campoS, i, input[4], input[9], input[10], input[8], y, x, input[0], input[1], addressfield.getText(), Integer.parseInt(portfield.getText()),Integer.parseInt(portfield.getText())), "coelho1");
        }
        else
            JOptionPane.showMessageDialog(null, "Nenhum ipo de cliente selecionado, impossivel continuar!");
    }//GEN-LAST:event_startbuttonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Client().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField addressfield;
    private javax.swing.JLabel addresslbl;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField portfield;
    private javax.swing.JLabel portlbl;
    private javax.swing.JRadioButton radiocarrot;
    private javax.swing.JRadioButton radiorabbit;
    private javax.swing.JButton startbutton;
    // End of variables declaration//GEN-END:variables

}
